package com.imooc.town.utils;

import com.imooc.town.enums.CodeEnum;

/**
 * create by song on 2018/3/26
 * To change this template use File | Settings | File Templates.
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(Integer code, Class<T> enumClass) {
        for (T each: enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
